package xuanke;

import java.io.*;

public class Systems implements Serializable{
    public static void main(String[] args) throws IOException{
        Curriculums gaoshu = new Curriculums("1", "高数", "101教室", "8:00");
        Curriculums wuli = new Curriculums("2", "物理", "102教室", "13:00");
        Curriculums yuwen = new Curriculums("3", "语文", "201教室", "10:00");
        Curriculums xiandai = new Curriculums("4", "线代", "202教室", "15:00");
        Curriculums lisan = new Curriculums("5", "离散", "301教室", "19:00");
        Curriculums tiyu = new Curriculums("6", "体育", "操场    ", "9:00");

        Teachers zhao=new Teachers("0001","赵老师",'男', new Curriculums[]{gaoshu,xiandai,lisan});
        Teachers zhang=new Teachers("0002","张老师",'男',new Curriculums[]{wuli});
        Teachers li=new Teachers("0003","李老师",'女',new Curriculums[]{yuwen});
        Teachers liu=new Teachers("004","刘老师",'男',new Curriculums[]{tiyu});

        gaoshu.setTeacher(zhao);
        xiandai.setTeacher(zhao);
        lisan.setTeacher(zhao);
        wuli.setTeacher(zhang);
        yuwen.setTeacher(li);
        tiyu.setTeacher(liu);

        Curriculums sIn1[]=new Curriculums[]{xiandai,lisan};
        Curriculums sIn2[]=new Curriculums[]{wuli,yuwen,xiandai,tiyu};
        Curriculums sIn3[]=new Curriculums[]{gaoshu,wuli,yuwen,tiyu};
        Students sOut1=new Students();
        Students sOut2=new Students();
        Students sOut3=new Students();

        Students StuWang=new Students("202001","王同学",'女',sIn1,2020);
        Students StuZhang=new Students("202101","张同学",'男',sIn2,2021);
        Students StuLi=new Students("202201","李同学",'女',sIn3,2022);

        FileOutputStream in = new FileOutputStream("/Users/weiboyang/Desktop/实验6/测试.txt");
        ObjectOutputStream inin = new ObjectOutputStream(in);
        inin.writeObject(StuWang);
        inin.writeObject(StuZhang);
        inin.writeObject(StuLi);

        FileInputStream out=new FileInputStream("/Users/weiboyang/Desktop/实验6/测试.txt");
        ObjectInputStream otot = new ObjectInputStream(out);
        try {
            sOut1= (Students)otot.readObject();
            sOut2= (Students)otot.readObject();
            sOut3= (Students)otot.readObject();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        sOut2.Tuike(wuli);
        sOut3.Tuike(gaoshu);
        sOut3.Tuike(tiyu);

        System.out.println(sOut1.toString());
        for(int i = 0; i<sOut1.curriculums.length; i++){
            System.out.println(sOut1.curriculums[i].toString());
        }

        System.out.println("\n"+sOut2.toString());
        for(int i = 0; i<sOut2.curriculums.length; i++){
            System.out.println(sOut2.curriculums[i].toString());
        }

        System.out.println("\n"+sOut3.toString());
        for(int i = 0; i<sOut3.curriculums.length; i++){
            System.out.println(sOut3.curriculums[i].toString());
        }
    }
}
